package org.jimmy.tang.concurrent.concurrentmap;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author jimmy
 * 
 */
public class ConcurrentSingleton {
    private static final ConcurrentMap<String, ConcurrentSingleton> map = new ConcurrentHashMap<String, ConcurrentSingleton>();
    private static ConcurrentSingleton instance;

    public static ConcurrentSingleton getInstance() {
        if (instance == null) {

            map.putIfAbsent("INSTANCE", new ConcurrentSingleton());

            instance = map.get("INSTANCE");
        }
        return instance;
    }

    private ConcurrentSingleton() {
    }
}
